﻿@model IEnumerable<RTW.Models.TMenu>

@{
    ViewData["Title"] = "菜单管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section head{
    <link href="/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet" />
    <style type="text/css">
        #dMain {
            width: 1200px;
            margin: 0 auto;
        }

        .dSearch .btn {
            margin-top: 10px;
        }

        .dSearch .form-control {
            display: inline-block;
        }

        .dSearch .layer-date {
            margin-top: -7px;
        }

        .dataTables_wrapper {
            padding-bottom: 0px;
        }

        div.dataTables_scrollBody table {
            margin-top: -18px !important;
        }

        .fixed-table-pagination .pagination-detail, .fixed-table-pagination div.pagination {
            margin-bottom: 0px;
        }
    </style>
}


<form id="form1" runat="server">
    <div id="dMain">
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="ibox" style="margin-bottom: 0px;">
                <div class="ibox-title">
                    <h5>@ViewBag.Title</h5>
                </div>
                <div class="ibox-content">
                    <div id="toolbar" class="dSearch">
                        <button class="btn btn-primary btn-sm" type="button" onclick="showPage('添加菜单','MenuEdit',800,650,true)">添加菜单</button>
                    </div>
                    <table id="tabData" class="table table-bordered">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>菜单名称</th>
                                <th>链接地址</th>
                                <th>类别</th>
                                <th>访问权限</th>
                                <th>索引</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <input id="hfLogInfo" type="hidden" value="删除了一条数据" />
    <input id="hfModular" type="hidden" value="申请审核" />
    <input id="hfPageUrl" type="hidden" value="@ViewBag.reurl" />
    @*<div id="dJson" style="display: none;"><%=GetJsonData() %></div>*@




    @*<uc1:dLeft runat="server" ID="dLeft" />*@
</form>
@section scripts{
    <script src="/js/plugins/jeditable/jquery.jeditable.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table-export.js"></script>
    <script src="/js/plugins/bootstrap-table/tableExport.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table-cookie.js"></script>

    <script src="/js/My97DatePicker/WdatePicker.js"></script>

    @*<script src="/js/verification.js"></script>*@


    <script type="text/javascript">

        //删除数据
        function Del(_ID) {
            _Confirm('确定要删除这条数据？', function () {
                $.ajax({
                    type: "post",
                    url: "DelMenu",
                    dataType: "json",
                    async: false,
                    data: {  ID: _ID },
                    success: function (result) {
                        if (result.success) {
                            location.href = location.href;
                        }
                    }
                })
            })
        }

        $(function () {
            var tabHeight = document.documentElement.clientHeight - 100;
            $('#tabData').bootstrapTable({
                height: tabHeight,
                //data: $("#dJson").text() != "" ? JSON.parse($("#dJson").text()) : "",
                url: "GetMenuForJson",
                dataType: "json",
                columns: [
                    //ImgPath MenuName PageUrl * Flag1
                    { align: 'center', width: "50px", checkbox: true },
                    {
                        align: 'left', width: "180px", formatter: function (value, row, index) {
                            return [
                                "<i class=\"" + row.ImgPath + "\"></i>&nbsp;" + row.MenuName
                            ]
                        }
                    },
                    { field: 'PageUrl', align: 'left', width: "180px", sortable: true },
                    { field: 'Bak2', align: 'center', width: "80px", sortable: true },
                    {
                        //align: 'left', formatter: function (value, row, index) {
                        //    var bakStr = "";
                        //    $.ajax({
                        //        type: "Post",
                        //        url: "GetBakName",
                        //        data: "{'Bak1':'" + row.Bak1 + "'}",
                        //        async: false,
                        //        dataType: "json",
                        //        contentType: "application/json; charset=utf-8",
                        //        success: function (msg) {
                        //            bakStr = msg.d;
                        //        }
                        //    });
                        //    return [
                        //        bakStr
                        //    ]
                        //}
                        field: 'Roles', align: 'left',
                    },
                    { field: 'Flag1', align: 'center', width: "70px", sortable: true },
                    { align: 'center', width: "100px", formatter: operateFormatter }
                ],
                toolbar: '#toolbar',//工具按钮用哪个容器
                buttonsClass: "sm btn-white",//按钮class
                pageSize: 100,//分页条数
                clickToSelect: true,//设置true将在点击行时，自动选择单选或复选框
                singleSelect: true,//为true则禁止多选
                cache: false,//是否缓存
                cookie: true,//是否启用cookie
                cookieIdTable: "MenuManager",//cookie键值
                pagination: true,//是否分页
                showColumns: true,//是否显示所有的列
                showRefresh: true,//是否显示刷新按钮
                search: true,//是否启用搜索
                showPaginationSwitch: true,//是否显示分页切换按钮
                showExport: true,//是否启用导出
                striped: false,//是否显示行间隔色
                onSearch: function (text) {
                    if (text != "") {
                        $("#tabData tbody tr td:not(.bs-checkbox)").each(function (i) {
                            var str = "<span class=\"bg-yellow\">" + text + "</span>";
                            var NewText = $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).text().replaceAll(text, str);
                            $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).html(NewText);
                        })
                    }
                }
            });
        })

        function operateFormatter(value, row, index) {
            return [
                "<a title=\"修改\" class=\"text-success\" href=\"javascript:;\" onclick=\"showPage('修改菜单信息','MenuEdit?ID=" + row.ID + "',800,650,true)\">编辑</a>&emsp;" +
                "<a title=\"删除\" class=\"text-danger\" href=\"javascript:;\" onclick=\"Del('DeleteMenu','" + row.ID + "')\">删除</a>"
            ];
        }
    </script>
}

